/**
 * @Title: ProjectServiceImpl.java 
 * @Description: TODO
 * @author <a href="mailto:psammead@126.com">Psammead</a>
 * @date 2011-7-16 下午03:51:34 
 * @version 1.0
 * Copyright 2011 by Psammead
 */
package com.psammead.dms.project.service.impl;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.psammead.dms.common.core.bo.Page;
import com.psammead.dms.project.dao.ProjectDao;
import com.psammead.dms.project.entity.Project;
import com.psammead.dms.project.service.ProjectService;

/**
 * @ClassName: ProjectServiceImpl
 * @Description: TODO
 * @author <a href="mailto:psammead@126.com">psammead</a>
 * @version 1.0
 * @date 2011-7-16
 */
@Service
public class ProjectServiceImpl implements ProjectService{

	@Resource
	private ProjectDao projectDao;
	/* (non-Javadoc)
	 * <p>Title: addProject</p>
	 * <p>Description: </p>
	 * @param project
	 * @see com.psammead.dms.project.service.ProjectService
	 * 		#addProject(com.psammead.dms.project.entity.Project)
	 */
	@Override
	public void addProject(Project project) {
		projectDao.save(project);
	}

	/* (non-Javadoc)
	 * <p>Title: updateProject</p>
	 * <p>Description: </p>
	 * @param project
	 * @see com.psammead.dms.project.service.ProjectService
	 * 		#updateProject(com.psammead.dms.project.entity.Project)
	 */
	@Override
	public void updateProject(Project project) {
		if(projectDao.exists(project.getId()))
			projectDao.save(project);
	}

	/* (non-Javadoc)
	 * <p>Title: getProject</p>
	 * <p>Description: </p>
	 * @param id
	 * @return
	 * @see com.psammead.dms.project.service.ProjectService
	 * 		#getProject(long)
	 */
	@Override
	public Project getProject(long id) {
		return projectDao.get(id);
	}

	/* (non-Javadoc)
	 * <p>Title: deleteProject</p>
	 * <p>Description: </p>
	 * @param id
	 * @see com.psammead.dms.project.service.ProjectService
	 * 		#deleteProject(long)
	 */
	@Override
	public void deleteProject(long id) {
		projectDao.remove(id); 
	}

	/* (non-Javadoc)
	 * <p>Title: queryProject</p>
	 * <p>Description: </p>
	 * @param paramMap
	 * @param sortMap
	 * @return
	 * @see com.psammead.dms.project.service.ProjectService
	 * 		#queryProject(java.util.Map, java.util.LinkedHashMap)
	 */
	@Override
	public List<Project> queryProject(Map<String, Object> paramMap,
			LinkedHashMap<String, String> sortMap) {
		return projectDao.queryResultList(paramMap, sortMap);
	}

	/* (non-Javadoc)
	 * <p>Title: queryProject</p>
	 * <p>Description: </p>
	 * @param paramMap
	 * @param sortMap
	 * @param pageNo
	 * @param pageSize
	 * @return
	 * @see com.psammead.dms.project.service.ProjectService
	 * 		#queryProject(java.util.Map, java.util.LinkedHashMap, int, int)
	 */
	@Override
	public Page<Project> queryProject(Map<String, Object> paramMap,
			LinkedHashMap<String, String> sortMap, int pageNo, int pageSize) {
		return projectDao.queryResultPage(paramMap, sortMap, pageNo, pageSize);
	}

	public ProjectDao getProjectDao() {
		return projectDao;
	}

	public void setProjectDao(ProjectDao projectDao) {
		this.projectDao = projectDao;
	}

}
